<script setup lang="ts">
defineOptions({
  name: "checkFiles"
});

import { ref, onMounted } from "vue";
import { queryFileList } from "@/api/modules/fab";
import FileUpload from "@/components/Upload/FileUpload.vue";

interface Props {
  ids?: Array<any>;
}

const props = withDefaults(defineProps<Props>(), {
  ids: () => []
});

const dialogTableVisible = defineModel({ type: Boolean, default: false });

const loading = ref<boolean>(false);
const title = ref<string>("查看文档");
//  图片上传类型add：新增，edit：编辑，view：查看
const uploadType = ref<string>("view");
const fileList = ref<Array<any>>([]);

const queryFileListFn = async () => {
  const { ids = [] } = props;
  if (!ids?.length) return;
  const params = { ids };
  loading.value = true;
  const res = await queryFileList(params, () => {
    loading.value = false;
  });
  loading.value = false;
  if (!res?.length) return;
  fileList.value = res;
};

const init = async () => {
  await queryFileListFn();
};

onMounted(async () => {
  await init();
});
</script>

<template>
  <px-dialog v-model="dialogTableVisible" :title="title" :width="800">
    <div class="check-files-content">
      <FileUpload :fileType="uploadType" :fileList="fileList" />
    </div>
  </px-dialog>
</template>

<!-- <style lang="scss" scoped>
.check-files-content {
}
</style> -->
